﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using NutriLeaf.Web.Model;

namespace NutriLeaf.Services.Core.ModuleVersion
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ModuleVersion" in code, svc and config file together.
    public class ModuleVersion : IModuleVersion
    {

        public void InsertModuleVersion(string moduleName)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            Web.Core.ModuleVersions.ModuleVersions.InsertModuleVersion(moduleName, ref context);
        }

        public bool Exists(string name)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            return Web.Core.ModuleVersions.ModuleVersions.Exists(name, ref context);
        }

        public void DeleteModule(string name)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            Web.Core.ModuleVersions.ModuleVersions.DeleteModule(name, ref context);
        }

        public int GetVersion(string name)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            return Web.Core.ModuleVersions.ModuleVersions.GetVersion(name, ref context);
        }

        public void UpdateVersion(string name, int number)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            Web.Core.ModuleVersions.ModuleVersions.UpdateVersion(name, number, ref context);
        }

        public void IncreaseVersion(string name)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            Web.Core.ModuleVersions.ModuleVersions.IncreaseVersion(name, ref context);
        }

        public void DecreaseVersion(string name)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            Web.Core.ModuleVersions.ModuleVersions.DecreaseVersion(name, ref context);
        }

        public Web.Model.ModuleVersion GetModule(string name)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            return Web.Core.ModuleVersions.ModuleVersions.GetModule(name, ref context);
        }


        public bool IsLatest(string name, int version)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            return Web.Core.ModuleVersions.ModuleVersions.IsLatest(name,version, ref context);
        }
    }
}
